package second.greedy;

public class Solution13 {
    public boolean lemonadeChange(int[] bills) {
        int five = 0;
        int ten = 0;
        for (int x : bills) {
            if (x == 5) {
                five++;
            } else if (x == 10) {
                ten++;
                five--;
            } else {
                if (ten > 0) {
                    ten--;
                    five--;
                } else five -= 3;
            }
            if (five < 0 || ten < 0) return false;
        }
        return true;
    }
}

